package day0224;

import java.util.Iterator;

public class Demo04 {

    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4};

        // for-each 循环, 被迭代的对象只要实现 Iterable 接口就可以
//        for (int c : arr) {
//            System.out.println(c);
//        }

        Container my = new Container(5);

        my.add("a");
        my.add("b");
        my.add("c");
        my.add("d");
        my.add("e");
//
//        for (Object obj : my){
//            System.out.println(obj);
//        }

        Iterator iterator = my.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
